<!-- 同城对比  comparison -->
<template>
	<view>
		<view class="heighly">
			<view class="boxbg u-rela" v-if='data.length > 0'>
				<view class="boxtop u-abso">
					<city-comparison :list='data' @getdele='getdele' @changeList="changeList" :type='type'></city-comparison>
				</view>
			</view>
			<view v-else>
				<list-empty list="data" :listHighly="highly" text='暂无数据'></list-empty>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: [],
				type: 0
			};
		},
		onLoad(e) {
			if (e.type) {
				this.type = +e.type;
				let a = e.type == 1 ? 'ershoufang' : 'xinfang';
				let list = uni.getStorageSync(a);
				if (!list.length) return;
				let res = JSON.parse(list);
				if (res) {
					this.data = res;
					this.data.map((pa, ia) => {
						if (pa) {
							this.data[ia].checked = false;
							this.data[ia].disabled = false;
						}
					})
				}
			}
			if (this.pageLoad) {
				setTimeout(() => {
					this.pageLoad = false;
				}, 1000);
			}
		},
		methods: {
			changeList(arr) {
				for (var i = 0; i < this.data.length; i++) {
					for (var j = 0; j < arr.length; j++) {
						if (this.data[i].id == arr[j]) {
							this.data[i].checked = true
						}
					}
				}
			},
			getdele(e){
				this.data = e;
			}
		},
	}
</script>

<style lang="scss" scoped>
	.boxbg {
		background-color: #0E5642;
		height: 200rpx;
	}

	.boxtop {
		top: 50rpx;
		left: 30rpx;
		right: 30rpx;
	}
</style>
